package com.ruoyi.map.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.map.domain.FhMapWatercommonfish;
import com.ruoyi.map.service.IFhMapWatercommonfishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 水域常见鱼种管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/map/watercommonfish")
public class FhMapWatercommonfishController extends BaseController
{
    @Autowired
    private IFhMapWatercommonfishService fhMapWatercommonfishService;

    /**
     * 查询水域常见鱼种管理列表
     */
    @PreAuthorize("@ss.hasPermi('map:watercommonfish:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhMapWatercommonfish fhMapWatercommonfish)
    {
        startPage();
        List<FhMapWatercommonfish> list = fhMapWatercommonfishService.selectFhMapWatercommonfishList(fhMapWatercommonfish);
        return getDataTable(list);
    }

    /**
     * 导出水域常见鱼种管理列表
     */
    @PreAuthorize("@ss.hasPermi('map:watercommonfish:export')")
    @Log(title = "水域常见鱼种管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhMapWatercommonfish fhMapWatercommonfish) throws IOException {
        List<FhMapWatercommonfish> list = fhMapWatercommonfishService.selectFhMapWatercommonfishList(fhMapWatercommonfish);
        ExcelUtil<FhMapWatercommonfish> util = new ExcelUtil<FhMapWatercommonfish>(FhMapWatercommonfish.class);
        util.exportExcel(response, list, "水域常见鱼种管理数据");
    }

    /**
     * 获取水域常见鱼种管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('map:watercommonfish:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhMapWatercommonfishService.selectFhMapWatercommonfishById(id));
    }

    /**
     * 新增水域常见鱼种管理
     */
    @PreAuthorize("@ss.hasPermi('map:watercommonfish:add')")
    @Log(title = "水域常见鱼种管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhMapWatercommonfish fhMapWatercommonfish)
    {
        return toAjax(fhMapWatercommonfishService.insertFhMapWatercommonfish(fhMapWatercommonfish));
    }

    /**
     * 修改水域常见鱼种管理
     */
    @PreAuthorize("@ss.hasPermi('map:watercommonfish:edit')")
    @Log(title = "水域常见鱼种管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhMapWatercommonfish fhMapWatercommonfish)
    {
        return toAjax(fhMapWatercommonfishService.updateFhMapWatercommonfish(fhMapWatercommonfish));
    }

    /**
     * 删除水域常见鱼种管理
     */
    @PreAuthorize("@ss.hasPermi('map:watercommonfish:remove')")
    @Log(title = "水域常见鱼种管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhMapWatercommonfishService.deleteFhMapWatercommonfishByIds(ids));
    }


    /**
     * 查询水域常见鱼种管理列表  限制为五条
     */
    //@PreAuthorize("@ss.hasPermi('map:watercommonfish:list')")
    @GetMapping("/commonfishList")
    public TableDataInfo commonfishList(FhMapWatercommonfish fhMapWatercommonfish)
    {
        List<FhMapWatercommonfish> list = fhMapWatercommonfishService.commonfishlist(fhMapWatercommonfish);
        return getDataTable(list);
    }
}
